import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, ManyToOne, JoinColumn } from 'typeorm'
import { User } from './user.entity'

@Entity()
export class Friendships {
    @PrimaryGeneratedColumn('uuid')
    friendships_id: string


    @Column({
        default: 0 // 0: 待处理 1: 已通过 2: 已拒绝 3: 冻结
    })
    status: number

    @Column({
        nullable: true
    })
    request_message: string | null

    @Column({
        default: 0
    })
    block_status: number // 0: 正常 1: 拉黑

    @Column({ default: false, select: false })
    isDelete: boolean;

    @CreateDateColumn({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP(6)', select: false })
    createdAt: Date;

    @CreateDateColumn({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP(6)', select: false })
    updatedAt: Date;

    // 关联用户表
    @ManyToOne(() => User, user => user.friendshipsUser)
    @JoinColumn({ name: 'user_id' })
    user: User

    // 关联用户表
    @ManyToOne(() => User, user => user.friendshipsFriend)
    @JoinColumn({ name: 'friend_id' })
    friend: User


}